Is the use of explicit ' == true' comparison always bad? [closed]
Posted
by
Slomojo
on Programmers
See other posts from Programmers
or by Slomojo
Published on 2011-11-15T23:03:22Z
Indexed on
2011/11/16
2:07 UTC
Read the original article
Hit count: 192
Possible Duplicate:
Make a big deal out of == true?
I've been looking at a lot of code samples recently, and I keep noticing the use of...
if( expression == true )
// do something...
and...
x = ( expression == true ) ? x : y;
I've tended to always use...
x = ( expression ) ? x : y;
and...
if( expression )
// do something...
Where == true
is implicit (and obvious?)
Is this just a habit of mine, and I'm being picky about the explicit use of == true
, or is it simply bad practice?
© Programmers or respective owner